﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.BaseService.Contract.Studio;
using DWF.Studio.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace DWF.Studio.BaseService
{
    /// <summary>
    /// 设计器窗口服务实现
    /// </summary>
    internal class WindowService : IWindowService
    {
        //主窗体
        private Window _mainWindow = null;
        public WindowService()
        {
            _mainWindow = App.Current.MainWindow;
        }

        /// <summary>
        /// 主窗体最大化
        /// </summary>
        public void MaximizeMainWindow()
        {
            if (_mainWindow.WindowState != System.Windows.WindowState.Maximized)
            {
                _mainWindow.WindowState = System.Windows.WindowState.Maximized;
            }
        }

        /// <summary>
        /// 主窗体最小化
        /// </summary>
        public void MinimizeMainWindow()
        {
            if (_mainWindow.WindowState != System.Windows.WindowState.Minimized)
            {
                _mainWindow.WindowState = System.Windows.WindowState.Minimized;
            }
        }
        /// <summary>
        ///主窗口还原
        /// </summary>
        public void ActivateWindows()
        {
            if (_mainWindow.WindowState == System.Windows.WindowState.Minimized)
            {
                SystemCommands.RestoreWindow(_mainWindow);
                _mainWindow.Activate();
            }
            //_mainWindow.Show();
            //_mainWindow.TopMost = true;
        }
        /// <summary>
        /// 设置窗体的主窗体
        /// </summary>
        /// <param name="window"></param>
        public void SetWindowOwner(Window window)
        {
            window.Owner = _mainWindow;
        }
    }
}
